package com.atguigu.cmsservice.controller;

import com.atguigu.cmsservice.entity.CrmBanner;
import com.atguigu.cmsservice.service.CrmBannerService;
import com.atguigu.commonutils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "网站首页幻灯片Banner列表")
@RestController
@RequestMapping("/cmsservice/bannerApi")
//@CrossOrigin
public class BannerApiController {

    @Autowired
    private CrmBannerService bannerService;

    @ApiOperation(value = "获取首页幻灯片banner")
    @GetMapping("getAllBanner")
    @Cacheable(value = "banners",key = "'bannerList'")
    public R index(){
        List<CrmBanner> itmes = bannerService.list(null);
        return R.ok().data("items",itmes);
    }
}
